﻿/*绘制八字墙 基础 截水墙 铺砌(内侧铺砌上缘中心点为0,0,0点)
            CheccWingWallData WingWallData = CheccWingWallData.Instance;
            WingWallData.angle_Lmax = 45;
            WingWallData.angle_Rmax = 35;
            WingWallData.angle_Lmin = 25;
            WingWallData.angle_Rmin = 15;
            CheccWingWall.Create();
            if (null != CheccWingWall.wingWall_L.Item1) CheccWingWall.wingWall_L.Item1.AddToModel();
            if (null != CheccWingWall.wingWall_L.Item2) CheccWingWall.wingWall_L.Item2.AddToModel();
            if (null != CheccWingWall.wingWall_L.Item3) CheccWingWall.wingWall_L.Item3.AddToModel();
            if (null != CheccWingWall.wingWall_L.Item4) CheccWingWall.wingWall_L.Item4.AddToModel();
            if (null != CheccWingWall.wingWall_L.Item5) CheccWingWall.wingWall_L.Item5.AddToModel();
            if (null != CheccWingWall.wingWall_L.Item6) CheccWingWall.wingWall_L.Item6.AddToModel();

            if (null != CheccWingWall.wingWall_R.Item1) CheccWingWall.wingWall_R.Item1.AddToModel();
            if (null != CheccWingWall.wingWall_R.Item2) CheccWingWall.wingWall_R.Item2.AddToModel();
            if (null != CheccWingWall.wingWall_R.Item3) CheccWingWall.wingWall_R.Item3.AddToModel();
            if (null != CheccWingWall.wingWall_R.Item4) CheccWingWall.wingWall_R.Item4.AddToModel();
            if (null != CheccWingWall.wingWall_R.Item5) CheccWingWall.wingWall_R.Item5.AddToModel();
            if (null != CheccWingWall.wingWall_R.Item6) CheccWingWall.wingWall_R.Item6.AddToModel();
 
 */

using Bentley.CifNET.GeometryModel.SDK.Edit;
using Bentley.GeometryNET;
using System.Collections.Generic;
using Bentley.DgnPlatformNET;
using Bentley.CifNET.LinearGeometry;
using System.Windows.Forms;
using System;
using BIM = Bentley.Interop.MicroStationDGN;
using BMI = Bentley.MstnPlatformNET.InteropServices;
using Bentley.DgnPlatformNET.Elements;
using System.Diagnostics;
using Bentley.CifNET.SDK;
using Bentley.CifNET.SDK.Edit;
using Bentley.CifNET.GeometryModel.SDK;
using BCL = Bentley.CifNET.LinearGeometry;
using System.IO;
using System.Linq;
using Bentley.MstnPlatformNET;
using Bentley.CifNET.Geometry;
using System.Runtime.InteropServices;
using System.Drawing;

namespace CheccCoverplateCulvertAssemble.Operation.HXD
{
    internal class CheccWingWall
    {
        private static DgnModelRef modelRef;
        private static DgnModel dgnmodel;
        private static double UOR = Bentley.MstnPlatformNET.Session.Instance.GetActiveDgnModelRef().GetModelInfo().UorPerMaster;
        private static DgnFile dgnFile = Session.Instance.GetActiveDgnFile();
        private static FileLevelCache lvlCachaActive = dgnFile.GetLevelCache();

        //Lmin Lmax 左洞小桩号  左洞大桩号 八字墙和基础
        //本软件定义的路线方向为： Y轴方向, 内侧铺砌上缘中心点为(0,0,0)点
        //左洞小桩号
        private static List<DPoint3d> lstPt_Top_Lmin =new List<DPoint3d>(); //八字墙顶面点
        private static List<DPoint3d> lstPt_Bottom_Lmin = new List<DPoint3d>(); //八字墙底面点
        private static List<DPoint3d> lstPt_baseTop_Lmin = new List<DPoint3d>(); //基础顶面点
        private static List<DPoint3d> lstPt_baseBottom_Lmin = new List<DPoint3d>(); //基础底面点
        //左洞大桩号
        private static List<DPoint3d> lstPt_Top_Lmax = new List<DPoint3d>(); //八字墙顶面点
        private static List<DPoint3d> lstPt_Bottom_Lmax = new List<DPoint3d>(); //八字墙底面点
        private static List<DPoint3d> lstPt_baseTop_Lmax = new List<DPoint3d>(); //基础顶面点
        private static List<DPoint3d> lstPt_baseBottom_Lmax = new List<DPoint3d>(); //基础底面点
        //右洞小桩号
        private static List<DPoint3d> lstPt_Top_Rmin = new List<DPoint3d>(); //八字墙顶面点
        private static List<DPoint3d> lstPt_Bottom_Rmin = new List<DPoint3d>(); //八字墙底面点
        private static List<DPoint3d> lstPt_baseTop_Rmin = new List<DPoint3d>(); //基础顶面点
        private static List<DPoint3d> lstPt_baseBottom_Rmin = new List<DPoint3d>(); //基础底面点
        //右洞大桩号
        private static List<DPoint3d> lstPt_Top_Rmax = new List<DPoint3d>(); //八字墙顶面点
        private static List<DPoint3d> lstPt_Bottom_Rmax = new List<DPoint3d>(); //八字墙底面点
        private static List<DPoint3d> lstPt_baseTop_Rmax = new List<DPoint3d>(); //基础顶面点
        private static List<DPoint3d> lstPt_baseBottom_Rmax = new List<DPoint3d>(); //基础底面点
        //八字墙 基础
        private static Tuple<Element, Element> Ele_Lmin = new Tuple<Element, Element>(null, null);
        private static Tuple<Element, Element> Ele_Lmax = new Tuple<Element, Element>(null, null);
        private static Tuple<Element, Element> Ele_Rmin = new Tuple<Element, Element>(null, null);
        private static Tuple<Element, Element> Ele_Rmax = new Tuple<Element, Element>(null, null);
        //铺砌 截水墙
        private static Tuple<Element, Element> pave_L = new Tuple<Element, Element>(null, null);
        private static Tuple<Element, Element> pave_R = new Tuple<Element, Element>(null,null);

        //左洞：小桩号八字墙 小桩号基础 铺砌 截水墙 大桩号八字墙 大桩号基础
        public static Tuple<Element, Element,Element,Element,Element,Element> wingWall_L = new Tuple<Element, Element, Element, Element, Element, Element>(null, null, null, null, null, null);
        //右洞：小桩号八字墙 小桩号基础 铺砌 截水墙 大桩号八字墙 大桩号基础
        public static Tuple<Element, Element, Element, Element, Element, Element> wingWall_R = new Tuple<Element, Element, Element, Element, Element, Element>(null, null, null, null, null, null);
        public static void Create()
        {
            CheccWingWallData WingWallData = CheccWingWallData.Instance;
            dgnmodel = SolidHelper.CreateModel(WingWallData.ModelName, DgnModelType.Normal, true, 1);
            modelRef = dgnmodel;
            //八字墙和基础
            Ele_Lmin=createWallAndFoundation(3,WingWallData.angle_Lmin);
            Ele_Lmax = createWallAndFoundation(2, WingWallData.angle_Lmax);
            Ele_Rmin = createWallAndFoundation(4, WingWallData.angle_Rmin);
            Ele_Rmax = createWallAndFoundation(1, WingWallData.angle_Rmax);
            //铺砌与截水墙
            createPaveAndCutoffWall_L();
            createPaveAndCutoffWall_R();
        }

        //构建左洞截水墙和铺砌
        private static void createPaveAndCutoffWall_L()
        {
            //Tuple<Element, Element> Ttemp = null;
            DPoint3d cutoffWall_topMaxPt = new DPoint3d();
            DPoint3d cutoffWall_topMinPt = new DPoint3d();

            CheccWingWallData WingWallData = CheccWingWallData.Instance;
            double juXX = -1;
            double paveOffset =WingWallData.paveOffset_L * juXX;
            double paveSlope= WingWallData.paveSlope_L;
            double offsetSlope = paveSlope * Math.Cos(Math.Abs(WingWallData.A_L - 90) * Math.PI / 180);

            double paveZ= WingWallData.paveZ_L;
            double distance=WingWallData.distance_L;
            //八字墙底面
            List<DPoint3d> bottom_min = new List<DPoint3d>();
            for (int i = 0; i < lstPt_Bottom_Lmin.Count; i++)
            {
                DPoint3d pt = new DPoint3d(lstPt_Bottom_Lmin[i].X, lstPt_Bottom_Lmin[i].Y - distance / 2.0, lstPt_Bottom_Lmin[i].Z);
                bottom_min.Add(pt);
            }
            List<DPoint3d> bottom_max = new List<DPoint3d>();
            for (int i = 0; i < lstPt_Bottom_Lmax.Count; i++)
            {
                DPoint3d pt = new DPoint3d(lstPt_Bottom_Lmax[i].X, lstPt_Bottom_Lmax[i].Y + distance / 2.0, lstPt_Bottom_Lmax[i].Z);
                bottom_max.Add(pt);
            }
            //基础顶面
            List<DPoint3d> baseTop_min = new List<DPoint3d>();
            for (int i = 0; i < lstPt_baseTop_Lmin.Count; i++)
            {
                DPoint3d pt = new DPoint3d(lstPt_baseTop_Lmin[i].X, lstPt_baseTop_Lmin[i].Y- distance/2.0, lstPt_baseTop_Lmin[i].Z);
                baseTop_min.Add(pt);    
            }
            List<DPoint3d> baseTop_max = new List<DPoint3d>();
            for (int i = 0; i < lstPt_baseTop_Lmax.Count; i++)
            {
                DPoint3d pt = new DPoint3d(lstPt_baseTop_Lmax[i].X, lstPt_baseTop_Lmax[i].Y + distance / 2.0, lstPt_baseTop_Lmax[i].Z);
                baseTop_max.Add(pt);
            }
            Element wall_min = SolidHelper.MoveElement(Ele_Lmin.Item1, DPoint3d.Zero, new DPoint3d(0, -distance / 2.0, -WingWallData.paveZ_L));
            Element base_min = SolidHelper.MoveElement(Ele_Lmin.Item2, DPoint3d.Zero, new DPoint3d(0, -distance / 2.0, -WingWallData.paveZ_L));
            Element wall_max = SolidHelper.MoveElement(Ele_Lmax.Item1, DPoint3d.Zero, new DPoint3d(0, distance / 2.0, -WingWallData.paveZ_L));
            Element base_max = SolidHelper.MoveElement(Ele_Lmax.Item2, DPoint3d.Zero, new DPoint3d(0, distance / 2.0, -WingWallData.paveZ_L));
            //计算铺砌顶面点集
            List<DPoint3d> listPave_Top = new List<DPoint3d>();
            //靠近洞身的点
            DPoint3d PT = new DPoint3d(0, -distance / 2.0, 0);
            listPave_Top.Add(PT);
            //八字墙低端内侧点
            PT = new DPoint3d(bottom_min[3].X, bottom_min[3].Y, 0 + offsetSlope * Math.Abs(bottom_min[3].X- bottom_min[0].X));
            listPave_Top.Add(PT);
            //八字墙低端外侧点
            PT = new DPoint3d(baseTop_min[2].X, baseTop_min[2].Y, 0 + offsetSlope * Math.Abs(baseTop_min[2].X - baseTop_min[0].X));
            listPave_Top.Add(PT);
            //八字墙低端外侧偏置点
            Line line = new Line(baseTop_min[2], baseTop_min[3]);
            LinearElement LE=line.GetOffsetElement(paveOffset);
            PT = new DPoint3d(LE.StartPoint.Coordinates.X, LE.StartPoint.Coordinates.Y, 0 + offsetSlope * Math.Abs(baseTop_min[2].X - baseTop_min[0].X+paveOffset));
            listPave_Top.Add(PT);
            cutoffWall_topMinPt = PT; cutoffWall_topMinPt.Z= cutoffWall_topMinPt.Z - WingWallData.thickness_pave;
            //八字墙低端外侧偏置点
            line = new Line(baseTop_max[2], baseTop_max[1]);
            LE = line.GetOffsetElement(-paveOffset);
            PT = new DPoint3d(LE.StartPoint.Coordinates.X, LE.StartPoint.Coordinates.Y, 0 + offsetSlope * Math.Abs(baseTop_max[2].X - baseTop_max[0].X + paveOffset));
            listPave_Top.Add(PT);
            cutoffWall_topMaxPt = PT; cutoffWall_topMaxPt.Z = cutoffWall_topMaxPt.Z - WingWallData.thickness_pave;
            //八字墙低端外侧点
            PT = new DPoint3d(baseTop_max[2].X, baseTop_max[2].Y, 0 + offsetSlope * Math.Abs(baseTop_max[2].X - baseTop_max[0].X));
            listPave_Top.Add(PT);
            //八字墙低端内侧点
            PT = new DPoint3d(bottom_max[1].X, bottom_max[1].Y, 0 + offsetSlope * Math.Abs(bottom_max[1].X - bottom_max[0].X));
            listPave_Top.Add(PT);
            //靠近洞身的点
            PT = new DPoint3d(0, distance / 2.0, 0);
            listPave_Top.Add(PT);
            //计算铺砌底面点集
            List<DPoint3d> listPave_Bottom = new List<DPoint3d>();
            for (int i = 0; i < listPave_Top.Count; i++)
            {
                DPoint3d pt = new DPoint3d(listPave_Top[i].X, listPave_Top[i].Y, listPave_Top[i].Z - WingWallData.thickness_pave);
                listPave_Bottom.Add(pt);    
            }

            //截水墙
            List<DPoint3d> cutOffWall_pts_top=new List<DPoint3d>();
            Line line1 = new Line (cutoffWall_topMaxPt,cutoffWall_topMinPt);
            LinearElement line2 = line1.GetOffsetElement(juXX * WingWallData.W_CutoffWall);
            cutOffWall_pts_top.Add(cutoffWall_topMinPt);
            cutOffWall_pts_top.Add(cutoffWall_topMaxPt);
            PT = line2.StartPoint.Coordinates;
            PT.Z=PT.Z- offsetSlope * WingWallData.W_CutoffWall;
            cutOffWall_pts_top.Add(PT);
            PT = line2.EndPoint.Coordinates;
            PT.Z = PT.Z - offsetSlope * WingWallData.W_CutoffWall;
            cutOffWall_pts_top.Add(PT);

            List<DPoint3d> cutOffWall_pts_bottom = new List<DPoint3d>();
            for (int i = 0; i < cutOffWall_pts_top.Count; i++)
            {
                DPoint3d ptTemp = new DPoint3d(cutOffWall_pts_top[i].X, cutOffWall_pts_top[i].Y, cutOffWall_pts_top[i].Z - WingWallData.H_CutoffWall);
                cutOffWall_pts_bottom.Add(ptTemp);
            }
            //铺砌
            Element pave = CheccPolyFaceSolid.Create(listPave_Top, listPave_Bottom, dgnmodel, WingWallData.paveLevelName, WingWallData.paveSolidColor, WingWallData.paveSolidLineStyle, 0);
            //存储铺砌数据
            BodyProperty.attachDataBlockToCubeCutoffWall(pave, WingWallData.thickness_pave.ToString(), WingWallData.solidName);
            //截水墙
            Element cutoffWall = CheccPolyFaceSolid.Create(cutOffWall_pts_top, cutOffWall_pts_bottom, dgnmodel, WingWallData.cutoffWallLevelName, WingWallData.cutoffWallSolidColor, WingWallData.cutoffWallSolidLineStyle, 0);
            //存储截水墙数据
            BodyProperty.attachDataBlockToCubePave(cutoffWall, line1.StartPoint.Coordinates.Distance(line1.EndPoint.Coordinates).ToString(), WingWallData.H_CutoffWall.ToString(), WingWallData.W_CutoffWall.ToString(), WingWallData.solidName);
            pave_L = new Tuple<Element, Element>(pave, cutoffWall);
            wingWall_L = new Tuple<Element, Element, Element, Element, Element, Element>(wall_min, base_min, pave_L.Item1, pave_L.Item2, wall_max, base_max);
        }

        //构建右洞截水墙和铺砌
        private static void createPaveAndCutoffWall_R()
        {
            //Tuple<Element, Element> Ttemp = null;
            DPoint3d cutoffWall_topMaxPt = new DPoint3d();
            DPoint3d cutoffWall_topMinPt = new DPoint3d();

            CheccWingWallData WingWallData = CheccWingWallData.Instance;
            double juXX = 1;
            double paveOffset = WingWallData.paveOffset_R * juXX;
            double paveSlope = WingWallData.paveSlope_R;
            double offsetSlope = paveSlope * Math.Cos(Math.Abs(WingWallData.A_R - 90) * Math.PI / 180);

            double paveZ = WingWallData.paveZ_R;
            double distance = WingWallData.distance_R;
            //八字墙底面
            List<DPoint3d> bottom_min = new List<DPoint3d>();
            for (int i = 0; i < lstPt_Bottom_Rmin.Count; i++)
            {
                DPoint3d pt = new DPoint3d(lstPt_Bottom_Rmin[i].X, lstPt_Bottom_Rmin[i].Y - distance / 2.0, lstPt_Bottom_Rmin[i].Z);
                bottom_min.Add(pt);
            }
            List<DPoint3d> bottom_max = new List<DPoint3d>();
            for (int i = 0; i < lstPt_Bottom_Rmax.Count; i++)
            {
                DPoint3d pt = new DPoint3d(lstPt_Bottom_Rmax[i].X, lstPt_Bottom_Rmax[i].Y + distance / 2.0, lstPt_Bottom_Rmax[i].Z);
                bottom_max.Add(pt);
            }
            //基础顶面
            List<DPoint3d> baseTop_min = new List<DPoint3d>();
            for (int i = 0; i < lstPt_baseTop_Rmin.Count; i++)
            {
                DPoint3d pt = new DPoint3d(lstPt_baseTop_Rmin[i].X, lstPt_baseTop_Rmin[i].Y - distance / 2.0, lstPt_baseTop_Rmin[i].Z);
                baseTop_min.Add(pt);
            }
            List<DPoint3d> baseTop_max = new List<DPoint3d>();
            for (int i = 0; i < lstPt_baseTop_Rmax.Count; i++)
            {
                DPoint3d pt = new DPoint3d(lstPt_baseTop_Rmax[i].X, lstPt_baseTop_Rmax[i].Y + distance / 2.0, lstPt_baseTop_Rmax[i].Z);
                baseTop_max.Add(pt);
            }
            //平移
            Element wall_min = SolidHelper.MoveElement(Ele_Rmin.Item1, DPoint3d.Zero, new DPoint3d(0, -distance / 2.0, -WingWallData.paveZ_L));
            Element base_min = SolidHelper.MoveElement(Ele_Rmin.Item2, DPoint3d.Zero, new DPoint3d(0, -distance / 2.0, -WingWallData.paveZ_L));
            Element wall_max = SolidHelper.MoveElement(Ele_Rmax.Item1, DPoint3d.Zero, new DPoint3d(0, distance / 2.0, -WingWallData.paveZ_L));
            Element base_max = SolidHelper.MoveElement(Ele_Rmax.Item2, DPoint3d.Zero, new DPoint3d(0, distance / 2.0, -WingWallData.paveZ_L));

            //计算铺砌顶面点集
            List<DPoint3d> listPave_Top = new List<DPoint3d>();
            //靠近洞身的点
            DPoint3d PT = new DPoint3d(0, -distance / 2.0, 0);
            listPave_Top.Add(PT);
            //八字墙低端内侧点
            PT = new DPoint3d(bottom_min[1].X, bottom_min[1].Y, 0 + offsetSlope * Math.Abs(bottom_min[1].X - bottom_min[0].X));
            listPave_Top.Add(PT);
            //八字墙低端外侧点
            PT = new DPoint3d(baseTop_min[2].X, baseTop_min[2].Y, 0 + offsetSlope * Math.Abs(baseTop_min[2].X - baseTop_min[0].X));
            listPave_Top.Add(PT);
            //八字墙低端外侧偏置点
            Line line = new Line(baseTop_min[2], baseTop_min[1]);
            LinearElement LE = line.GetOffsetElement(paveOffset);
            PT = new DPoint3d(LE.StartPoint.Coordinates.X, LE.StartPoint.Coordinates.Y, 0 + offsetSlope * Math.Abs(baseTop_min[2].X - baseTop_min[0].X + paveOffset));
            listPave_Top.Add(PT);
            cutoffWall_topMinPt = PT; cutoffWall_topMinPt.Z = cutoffWall_topMinPt.Z - WingWallData.thickness_pave;
            //八字墙低端外侧偏置点
            line = new Line(baseTop_max[2], baseTop_max[3]);
            LE = line.GetOffsetElement(-paveOffset);
            PT = new DPoint3d(LE.StartPoint.Coordinates.X, LE.StartPoint.Coordinates.Y, 0+ offsetSlope * Math.Abs(baseTop_max[2].X - baseTop_max[0].X + paveOffset));
            listPave_Top.Add(PT);
            cutoffWall_topMaxPt = PT; cutoffWall_topMaxPt.Z = cutoffWall_topMaxPt.Z - WingWallData.thickness_pave;
            //八字墙低端外侧点
            PT = new DPoint3d(baseTop_max[2].X, baseTop_max[2].Y, 0 + offsetSlope * Math.Abs(baseTop_max[2].X - baseTop_max[0].X));
            listPave_Top.Add(PT);
            //八字墙低端内侧点
            PT = new DPoint3d(bottom_max[3].X, bottom_max[3].Y, 0 + offsetSlope * Math.Abs(bottom_max[3].X - bottom_max[0].X));
            listPave_Top.Add(PT);
            //靠近洞身的点
            PT = new DPoint3d(0, distance / 2.0, 0);
            listPave_Top.Add(PT);
            //计算铺砌底面点集
            List<DPoint3d> listPave_Bottom = new List<DPoint3d>();
            for (int i = 0; i < listPave_Top.Count; i++)
            {
                DPoint3d pt = new DPoint3d(listPave_Top[i].X, listPave_Top[i].Y, listPave_Top[i].Z - WingWallData.thickness_pave);
                listPave_Bottom.Add(pt);
            }
            //截水墙
            List<DPoint3d> cutOffWall_pts_top = new List<DPoint3d>();
            Line line1 = new Line(cutoffWall_topMaxPt, cutoffWall_topMinPt);
            LinearElement line2 = line1.GetOffsetElement(juXX * WingWallData.W_CutoffWall);
            cutOffWall_pts_top.Add(cutoffWall_topMinPt);
            cutOffWall_pts_top.Add(cutoffWall_topMaxPt);
            PT = line2.StartPoint.Coordinates;
            PT.Z = PT.Z - offsetSlope * WingWallData.W_CutoffWall;
            cutOffWall_pts_top.Add(PT);
            PT = line2.EndPoint.Coordinates;
            PT.Z = PT.Z - offsetSlope * WingWallData.W_CutoffWall;
            cutOffWall_pts_top.Add(PT);

            List<DPoint3d> cutOffWall_pts_bottom = new List<DPoint3d>();
            for (int i = 0; i < cutOffWall_pts_top.Count; i++)
            {
                DPoint3d ptTemp = new DPoint3d(cutOffWall_pts_top[i].X, cutOffWall_pts_top[i].Y, cutOffWall_pts_top[i].Z - WingWallData.H_CutoffWall);
                cutOffWall_pts_bottom.Add(ptTemp);
            }
            //铺砌
            Element pave = CheccPolyFaceSolid.Create(listPave_Top, listPave_Bottom, dgnmodel, WingWallData.paveLevelName, WingWallData.paveSolidColor, WingWallData.paveSolidLineStyle, 0);
            //存储铺砌数据
            BodyProperty.attachDataBlockToCubeCutoffWall(pave, WingWallData.thickness_pave.ToString(), WingWallData.solidName);
            //截水墙
            Element cutoffWall = CheccPolyFaceSolid.Create(cutOffWall_pts_top, cutOffWall_pts_bottom, dgnmodel, WingWallData.cutoffWallLevelName, WingWallData.cutoffWallSolidColor, WingWallData.cutoffWallSolidLineStyle, 0);
            //存储截水墙数据
            BodyProperty.attachDataBlockToCubePave(cutoffWall, line1.StartPoint.Coordinates.Distance(line1.EndPoint.Coordinates).ToString(), WingWallData.H_CutoffWall.ToString(), WingWallData.W_CutoffWall.ToString(),WingWallData.solidName);
            pave_R = new Tuple<Element, Element>(pave, cutoffWall);
            wingWall_R = new Tuple<Element, Element, Element, Element, Element, Element>(wall_min, base_min, pave_R.Item1, pave_R.Item2, wall_max, base_max);
        }

        //构建八字墙和基础
        private static Tuple<Element, Element> createWallAndFoundation(int quadrantNumber,double angle_innerEdge)
        {
            Tuple<Element, Element> Ttemp = null;
            List<DPoint3d> lstPt_Top = new List<DPoint3d>(); //八字墙顶面点
            List<DPoint3d> lstPt_Bottom = new List<DPoint3d>(); //八字墙底面点 
            List<DPoint3d> lstPt_baseTop = new List<DPoint3d>(); //基础顶面点
            List<DPoint3d> lstPt_baseBottom = new List<DPoint3d>(); //基础底面点 
            CheccWingWallData WingWallData = CheccWingWallData.Instance;
            //将八字墙最高点截面内侧最低点定义为(0,0,0), 用下面的数据定义计算点的方向
            double juXX = 1, juYY = 1;
            if (quadrantNumber == 1) //第一象限
            {
                juXX = 1; juYY = 1;
            }
            else if (quadrantNumber == 2) //第二象限
            {
                juXX = -1; juYY = 1;
            }
            else if (quadrantNumber == 3) //第三象限
            {
                juXX = -1; juYY = -1;
            }
            else //第四象限
            {
                juXX = 1; juYY = -1;
            }
            //Xn表示X轴方向距离原点最近 Yn表示Y轴方向距离原点最近  Xw表示X轴方向距离原点最远 Yw表示Y轴方向距离原点最远
            //八字墙顶面的点
            DPoint3d topPt_XnYn = new DPoint3d(0, 0, WingWallData.H_max);
            DPoint3d topPt_XnYw = new DPoint3d(topPt_XnYn.X, topPt_XnYn.Y + juYY * WingWallData.W_topWall, topPt_XnYn.Z);
            double A = angle_innerEdge * Math.PI / 180;
            double l = (WingWallData.H_max- WingWallData.H_min) * WingWallData.slope_subgrade / Math.Cos(A);
            DPoint3d topPt_XwYn = new DPoint3d(topPt_XnYn.X + juXX * l * Math.Cos(A), topPt_XnYn.Y + juYY * l * Math.Sin(A), WingWallData.H_min);
            DPoint3d topPt_XwYw = new DPoint3d(topPt_XwYn.X, topPt_XwYn.Y + juYY * WingWallData.W_topWall, WingWallData.H_min);
            //八字墙底面的点
            DPoint3d bottomPt_XnYn = new DPoint3d(0, 0, 0);
            DPoint3d bottomPt_XnYw = new DPoint3d(bottomPt_XnYn.X, bottomPt_XnYn.Y + juYY * (WingWallData.W_topWall + WingWallData.H_max / WingWallData.slope_outerVerticalWall), 0);
            DPoint3d bottomPt_XwYn = new DPoint3d(topPt_XwYn.X, topPt_XwYn.Y, 0);
            DPoint3d bottomPt_XwYw = new DPoint3d(bottomPt_XwYn.X, bottomPt_XwYn.Y + juYY * (WingWallData.W_topWall + WingWallData.H_min / WingWallData.slope_outerVerticalWall), 0);
            string bottomWidth = bottomPt_XnYn.Distance(bottomPt_XnYw).ToString();

            //按照顺时针方向(顶视图)将点加入到list中
            lstPt_Top.Clear();
            lstPt_Bottom.Clear();
            lstPt_baseTop.Clear();
            lstPt_baseBottom.Clear();
            if (quadrantNumber == 1 || quadrantNumber == 3) //顶视图方向  顺时针加入点
            {
                lstPt_Top.Add(topPt_XnYn); lstPt_Top.Add(topPt_XnYw);
                lstPt_Top.Add(topPt_XwYw); lstPt_Top.Add(topPt_XwYn);
                lstPt_Bottom.Add(bottomPt_XnYn); lstPt_Bottom.Add(bottomPt_XnYw);
                lstPt_Bottom.Add(bottomPt_XwYw); lstPt_Bottom.Add(bottomPt_XwYn);
                //基础
                DPoint3d pt_XnYn = new DPoint3d(bottomPt_XnYn.X, bottomPt_XnYn.Y - juYY * WingWallData.W_innerEdge, bottomPt_XnYn.Z);
                lstPt_baseTop.Add(pt_XnYn); lstPt_baseBottom.Add(new DPoint3d(pt_XnYn.X, pt_XnYn.Y, pt_XnYn.Z-WingWallData.foundationThickness));
                DPoint3d pt_XnYw = new DPoint3d(bottomPt_XnYw.X, bottomPt_XnYw.Y + juYY * WingWallData.W_outerEdge, bottomPt_XnYw.Z);
                lstPt_baseTop.Add(pt_XnYw); lstPt_baseBottom.Add(new DPoint3d(pt_XnYw.X, pt_XnYw.Y, pt_XnYw.Z - WingWallData.foundationThickness));
                DPoint3d pt_XwYw = new DPoint3d(bottomPt_XwYw.X, bottomPt_XwYw.Y + juYY * WingWallData.W_outerEdge, bottomPt_XwYw.Z);
                lstPt_baseTop.Add(pt_XwYw); lstPt_baseBottom.Add(new DPoint3d(pt_XwYw.X, pt_XwYw.Y, pt_XwYw.Z - WingWallData.foundationThickness));
                DPoint3d pt_XwYn = new DPoint3d(bottomPt_XwYn.X, bottomPt_XwYn.Y - juYY * WingWallData.W_innerEdge, bottomPt_XwYw.Z);
                lstPt_baseTop.Add(pt_XwYn); lstPt_baseBottom.Add(new DPoint3d(pt_XwYn.X, pt_XwYn.Y, pt_XwYn.Z - WingWallData.foundationThickness));
                //拷贝点
                if (quadrantNumber == 1)
                {
                    lstPt_Top_Rmax = new List<DPoint3d>(lstPt_Top);
                    lstPt_Bottom_Rmax = new List<DPoint3d>(lstPt_Bottom);
                    lstPt_baseTop_Rmax = new List<DPoint3d>(lstPt_baseTop);
                    lstPt_baseBottom_Rmax = new List<DPoint3d>(lstPt_baseBottom);
                }
                else
                {
                    lstPt_Top_Lmin = new List<DPoint3d>(lstPt_Top);
                    lstPt_Bottom_Lmin = new List<DPoint3d>(lstPt_Bottom);
                    lstPt_baseTop_Lmin = new List<DPoint3d>(lstPt_baseTop);
                    lstPt_baseBottom_Lmin = new List<DPoint3d>(lstPt_baseBottom);
                }
            }
            else
            {
                lstPt_Top.Add(topPt_XnYn); lstPt_Top.Add(topPt_XwYn);
                lstPt_Top.Add(topPt_XwYw); lstPt_Top.Add(topPt_XnYw);
                lstPt_Bottom.Add(bottomPt_XnYn); lstPt_Bottom.Add(bottomPt_XwYn);
                lstPt_Bottom.Add(bottomPt_XwYw); lstPt_Bottom.Add(bottomPt_XnYw);
                //基础
                DPoint3d pt_XnYn = new DPoint3d(bottomPt_XnYn.X, bottomPt_XnYn.Y - juYY * WingWallData.W_innerEdge, bottomPt_XnYn.Z);
                lstPt_baseTop.Add(pt_XnYn); lstPt_baseBottom.Add(new DPoint3d(pt_XnYn.X, pt_XnYn.Y, pt_XnYn.Z - WingWallData.foundationThickness));
                DPoint3d pt_XwYn = new DPoint3d(bottomPt_XwYn.X, bottomPt_XwYn.Y - juYY * WingWallData.W_innerEdge, bottomPt_XwYw.Z);
                lstPt_baseTop.Add(pt_XwYn); lstPt_baseBottom.Add(new DPoint3d(pt_XwYn.X, pt_XwYn.Y, pt_XwYn.Z - WingWallData.foundationThickness));
                DPoint3d pt_XwYw = new DPoint3d(bottomPt_XwYw.X, bottomPt_XwYw.Y + juYY * WingWallData.W_outerEdge, bottomPt_XwYw.Z);
                lstPt_baseTop.Add(pt_XwYw); lstPt_baseBottom.Add(new DPoint3d(pt_XwYw.X, pt_XwYw.Y, pt_XwYw.Z - WingWallData.foundationThickness));
                DPoint3d pt_XnYw = new DPoint3d(bottomPt_XnYw.X, bottomPt_XnYw.Y + juYY * WingWallData.W_outerEdge, bottomPt_XnYw.Z);
                lstPt_baseTop.Add(pt_XnYw); lstPt_baseBottom.Add(new DPoint3d(pt_XnYw.X, pt_XnYw.Y, pt_XnYw.Z - WingWallData.foundationThickness));
                if (quadrantNumber == 2)
                {
                    lstPt_Top_Lmax = new List<DPoint3d>(lstPt_Top);
                    lstPt_Bottom_Lmax = new List<DPoint3d>(lstPt_Bottom);
                    lstPt_baseTop_Lmax = new List<DPoint3d>(lstPt_baseTop);
                    lstPt_baseBottom_Lmax = new List<DPoint3d>(lstPt_baseBottom);
                }
                else
                {
                    lstPt_Top_Rmin = new List<DPoint3d>(lstPt_Top);
                    lstPt_Bottom_Rmin = new List<DPoint3d>(lstPt_Bottom);
                    lstPt_baseTop_Rmin = new List<DPoint3d>(lstPt_baseTop);
                    lstPt_baseBottom_Rmin = new List<DPoint3d>(lstPt_baseBottom);
                }
            }
            Element wingWall = CheccPolyFaceSolid.Create(lstPt_Top, lstPt_Bottom, dgnmodel, WingWallData.LevelName, WingWallData.solidColor, WingWallData.solidLineStyle, 0);
            Element wingWallFoundation = CheccPolyFaceSolid.Create(lstPt_baseTop, lstPt_baseBottom, dgnmodel, WingWallData.baseLevelName, WingWallData.baseSolidColor, WingWallData.baseSolidLineStyle, 0);
            //存储八字墙和八字墙基础数据
            BodyProperty.attachDataBlockToCubeAliform(wingWall, wingWallFoundation, Math.Abs( lstPt_Top[0].Y- lstPt_Top[2].Y).ToString(), WingWallData.H_max.ToString(), WingWallData.W_topWall.ToString(), bottomWidth, angle_innerEdge.ToString(), WingWallData.slope_subgrade.ToString(), "0", WingWallData.W_innerEdge.ToString(), WingWallData.W_outerEdge.ToString(), WingWallData.foundationThickness.ToString(), WingWallData.solidName);
            Ttemp = new Tuple<Element, Element>(wingWall, wingWallFoundation);
            return Ttemp;

        }
    }
}
